<template>
	<view class="apps">
		<uv-navbar placeholder>
			<template v-slot:left>
				<view class="flex aic">
					<view class="flex jcc bdr100 bd1s bdb1 bdl1 bdr1 bdt1" >
						<uv-icon name="home" size="19" @click="handleIndex()"></uv-icon>
					</view>
					<view class="f16 fw600 ml20">设备</view>
					<view class="f14 fw400 ml20" @click="handleTab('/pages/facility/facility',0)">场地</view>
					<view class="f14 fw400 ml20" @click="handle('/pages/facility/service',0)">服务</view>
				</view>
			</template>
		</uv-navbar>
		<view class="mt20 plr10">
				<uv-grid :border="false" col="2" v-if="list.length > 0">
					<uv-grid-item v-for="(item,index) in list" :key="index">
						<view class="flex fdc mb20 pr plr10">
							<image :src="item.image" mode="widthFix" style="width: 345rpx; height:240rpx;"></image>
							<view class="bgwhite t2hd f26r c333">{{item.title}}</view>
							<view class="flex jcsb">
								<view class="flex fdc">
									<view class="mt10 flex jcc f26r c35b5f5"></view>
								</view>
								<uv-button open-type="contact" @contact="contactBack" customStyle="height:auto;border-width:0 !important;">
									<view class="flex fdc">
										<view class="mt10  flex jcc f26r cf5a957">咨询客服</view>
									</view>
								</uv-button>
							</view>
						</view>
					</uv-grid-item>
				</uv-grid>
			</view>
		</view>
	</template>
	
	<script setup>
		import { util } from '@/common/util.js'
		import { ref , reactive, nextTick, computed } from 'vue'
		import { onLoad, onShow, onHide,onReachBottom } from '@dcloudio/uni-app'
		const list =ref([]),page=ref(1),more=ref(true)
		let arrs = reactive({
			page:1,
			more:true,
		})
		const handle=(e)=>{
			uni.navigateTo({
				url:e,
			})
		},handleBack = ()=>{
			uni.navigateBack()
		},handleIndex = ()=>{
			uni.switchTab({
				url:"/pages/index/index"
			})
		},handleTabs = (e) =>{
			arrs = Object.assign(arrs,e);
			arrs.page = 1;
			arrs.more = true;
			getList()
			
		},getList = ()=>{
			util.request({url:"/facility/device",type:"post",data:arrs}).then((rlt)=>{
				if(rlt.code == 1){
					if(arrs.page == 1){
						list.value =rlt.data
					}else{
						list.value.push(... rlt.data);
					}
					if(rlt.data.length<10){
						arrs.more=false
					}
					arrs.page++;
				}
			})
		},contactBack = (e)=>{
		console.log(e);
	}
		onLoad(()=>{
			getList()
		})
		onReachBottom(()=>{
			if(arrs.more){
				getList()
			}
		})
	</script>